package model.service;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import model.dao.ProjectDAO;
import model.vo.MplistVO;

public class ProjectServiceImpl implements ProjectService {
	private ProjectDAO projectDAO;
	@Override
	public void setProjectDAO(ProjectDAO projectDAO) {
		this.projectDAO = projectDAO;
	}
	
	
	//마감 적용
	@Override
	public void Magam_apply(String pro_id, String projectGubun) throws SQLException{
		HashMap map=new HashMap();
		map.put("pro_id",Integer.parseInt(pro_id));
		map.put("projectGubun",Integer.parseInt(projectGubun));
		projectDAO.Magam_apply(map);
	}
	//마감 적용
	@Override
	public void Magam_cancel(String pro_id, String projectGubun) throws SQLException{
		HashMap map=new HashMap();
		map.put("pro_id",Integer.parseInt(pro_id));
		map.put("projectGubun",Integer.parseInt(projectGubun));
		projectDAO.Magam_cancel(map);
	}
	
	
	//최대 순번 구하기
	public int maxNo(String menuName) throws SQLException{
			int maxNo=0;
		if(menuName.equals("mplist_maxNo")){
			maxNo=projectDAO.mplist_maxNo();
		}
		return maxNo;
	}
	
	//[프로젝트 관리]
	//프로젝트 관리
	@Override
	public List mplist(String pro_loginID) throws SQLException {
		return projectDAO.mplist(pro_loginID);
	}
	//autoPro_pindex 순번 구하기
	@Override
	public int autoPro_pindex(String pro_sday) throws SQLException {
		return projectDAO.autoPro_pindex(pro_sday);
	}
	//착수일의 iap버전 검색 
	@Override
	public boolean identity_pro_pindex(String pro_sday, String pro_pindex) throws SQLException {
		// TODO Auto-generated method stub
		MplistVO vo=new MplistVO();
		vo.setPro_sday(pro_sday);
		vo.setPro_pindex(Integer.parseInt(pro_pindex));
		return projectDAO.identity_pro_pindex(vo);
	}
	//프로젝트 관리 등록
	@Override
	public void mplist_insert(MplistVO vo) throws SQLException {
		projectDAO.mplist_insert(vo);
	}
	//프로젝트 관리 삭제
	@Override
	public void mplist_delete(String proId) throws SQLException {
		int pro_id=Integer.parseInt(proId);
		projectDAO.mplist_delete(pro_id);
	}
	//프로젝트 관리 수정 페이지로 이동
	@Override
	public MplistVO mplist_updatePage(String proId) throws SQLException {
		int pro_id=Integer.parseInt(proId);
		return projectDAO.mplist_updatePage(pro_id);
	}
	//프로젝트 관리 수정
	@Override
	public void mplist_update(MplistVO vo) throws SQLException {
		projectDAO.mplist_update(vo);
	}
	
	//[프로젝트 적용]
	//회차별 카운트
	@Override
	public List proSelectCount(int pro_id) throws SQLException {
		System.out.println(pro_id);
		return projectDAO.proSelectCount(pro_id);
	}
	//회차별 카운트
	@Override
	public List proSelectCountVO(int pro_id) throws SQLException {
		System.out.println(pro_id);
		return projectDAO.proSelectCountVO(pro_id);
	}

	//프로젝트 복사생성(등록)
	@Override
	public void mplist_SC_insert(Map map) throws SQLException {
		// TODO Auto-generated method stub
		projectDAO.mplist_SC_insert(map);
	}
}
